﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MINERP.BLL.InfoConfig;
using MINERP.MODEL.FoundationModel;

namespace MINERP.InfoConfig
{
    public partial class FrmProductCommomItem : Form
    {
        public FrmProductCommomItem()
        {
            InitializeComponent();
        }
        private static FrmProductCommomItem instance = null;

        public static FrmProductCommomItem Instance
        {
            get
            {
                if (instance == null)
                    instance = new FrmProductCommomItem();
                return instance;
            }

        }
        private void btnUpdateShop_Click(object sender, EventArgs e)
        {
            gcSelect.OptionsColumn.ReadOnly = false;
            simpleButtonSave.Enabled = true;
            btnUpdateShop.Enabled = false;
        }
        ProductCommomChargeItemBLL _bll = new ProductCommomChargeItemBLL();
        private void FrmProductCommomItem_Load(object sender, EventArgs e)
        {
            gcSelect.OptionsColumn.ReadOnly = true;
            simpleButtonSave.Enabled = false;
            List<ProductCommonChargeItem_Info> AllProduct = _bll.GetAllProductCommonItem();
            gridControlProduct.DataSource = AllProduct;
        }

        private void simpleButtonSave_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("是否要更改" + CurrProductCommonCharge.ProductName + "的附加收费项目", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.OK)
            {
                try
                {
                    this.Cursor = Cursors.WaitCursor;
                    _bll.UpdataProductCommonItem(CurrProductCommonCharge);
                    this.Cursor = Cursors.Default;
                    MessageBox.Show("更新成功","提示",MessageBoxButtons.OKCancel,MessageBoxIcon.Information);
                }
                catch (Exception ex)
                {

                }
                finally
                {
                    this.Cursor = Cursors.Default;
                }

            }
            gcSelect.OptionsColumn.ReadOnly = true;
            btnUpdateShop.Enabled = true;
            simpleButtonSave.Enabled = false;

        }

        private void simpleButtonCancel_Click(object sender, EventArgs e)
        {
            gcSelect.OptionsColumn.ReadOnly = true;
            simpleButtonSave.Enabled = false ;
            simpleButtonSave.Enabled = false;
        }
        ProductCommonChargeItem_Info CurrProductCommonCharge = new ProductCommonChargeItem_Info();
        private void gridViewProduct_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e)
        {
            if (e.RowHandle >= 0)
            {
                ProductCommonChargeItem_Info info = (ProductCommonChargeItem_Info)gridViewProduct.GetRow(e.RowHandle);
                CurrProductCommonCharge = info;
                gridControlCommonItems.DataSource = info.CommonChargeItem;
                gridControlCommonItems.RefreshDataSource();
            }
        }
    }
}
